import requests
import json

url = 'https://act-api-takumi-static.mihoyo.com/content_v2_user/app/1963de8dc19e461c/getContentList?iPage=1&iPageSize=999&sLangKey=zh-cn&isPreview=0&iChanId=253'


res = requests.get(url)


# 解析JSON数据
data = res.json()


# 获取列表数据
items = data.get("data", {}).get("list", [])

# 使用 for-in 遍历列表
for e in items:
    SExt = e["sExt"]
    hero_name = e["sTitle"]
    parsed_sExt = json.loads(SExt)  # 解析JSON字符串

    for E in parsed_sExt["poster"]:
        url = E["url"]
        print(hero_name, f"{url}")

        # res_head = requests.get(url)
        # with open(f"./static/{hero_name}.jpg", "wb") as f:
        #     f.write(res_head.content)



